#ifndef __AI_MOVE_H__
#define __AI_MOVE_H__

#include "ai_common.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>


// Set the Max Angle and Max Lineal velocity of the robots
// It values are taken from server at handshacking protocol
void ai_set_MaxLin_Vel(int vel);
void ai_set_MaxAng_Vel(int vel);


/********************** Set Movement Priority Order **********************/
// Indicates which team own the ball
// give true if our team own's the ball, false if not.
// also return true if both teams ara so close.
int set_teamOwn_ball(stateGame *state);

// Indicates which is the domination robot between ours robots
int ai_give_domination_robot(stateGame *state);
// Set at global table: domRobotList
//Coloca els nostres robots en ordre en funcio de la proximitat a la pilota
void set_domination_robot_order(stateGame *state);
// Set at global table: domRobotListTheirs
// Coloca els seus robots en ordre segons la seva proximitat a la pilota
void set_domination_robot_theirs(stateGame *state);
/*************************** Field Subdivisions **************************/
// Get the identifier of the zone where the robot are.
int get_robot_zone(int row, int col);
// Set our own field, it depends of the round that we are playing
int set_own_field(stateGame *state);
// Busca quin es el porter dins dels nostres jugadors
// i quin es el nostre camp; (-1 esquerra, 1 dreta)
void set_initial_values(stateGame *state);
/************************* Basic Robot Movements *************************/
//Indicates if there are obstacles in trajectory between ball (row,col) and robot
//Check: distance SHOT_CLEAN_AREA source
//		 distance SHOT_CLEAN_AREA destination
//		 distance SHOT_CLEAN_AREA half path between source and destination
// return 1: yes (TRUE)  -- 0:false (FALSE);
// return parameter dir : -1 left, 1 right , 0 push 
int ai_obstacles_in_trajec(stateGame *state, int row,int col, int dst, int *dir);

// Set the robot that must shoot by the parameter index
// Set if the shot goes to the nearest 1 or to the farest robot
void ai_set_shoot(stateGame *state, movements *mov,int index);
void ai_get_shoot_rotate_force(stateGame *state, movements *mov,int index, int nearest);

// returns the existing angel between two point {(row1,col1),(row2,col2)} i a cartagian space
int ai_set_Vectang(int row1, int col1, int row2, int col2);
// Set the angular and lineal Velocity to move the robot between the ball and goal
// Index identifies the robot
void ai_pos_normal_ball_goal(stateGame *state, movements *mov,int index);

void ai_set_linVel_robot(stateGame *state, movements *mov, int index, int row, int col);
void ai_set_angVel_robot(stateGame *state, movements *mov, int index, int row, int col);

// returns the angular velocity needed to get an determined orientation
int ai_set_angVel(stateGame *state, movements *mov, int orientation);

// Defineix moviments amb velocitat lineal i angular conjuntament
void ai_set_Vel_robot(stateGame *state, movements *mov, int index, int row, int col);
void ai_set_Vel_robot_Simple(stateGame *state, movements *mov, int index, int row, int col);

void ai_set_aproximation(stateGame *state,movements *mov,int index,int ball_row,int ball_col,int row,int col);
void ai_set_Vel_robot_Simple(stateGame *state, movements *mov, int index, int row, int col);
/************************ Distances Mesures *************************/
float ai_euclidean_distance(int row1, int col1, int row2, int col2);
float ai_manhattan_distance(int row1, int col1, int row2, int col2);


/************************ Robot Movements ***************************/
void ai_goalkeeper_move(stateGame *state, movements *mov);
void ai_defender_MayAtac_move(stateGame *state, movements *mov, int index,int up);
void ai_defender_NoAtac_move(stateGame *state, movements *mov, int index);
void ai_Killer_move(stateGame *state, movements *mov, int index);
void ai_robot_tonto(stateGame *state, movements *mov,int index);
//---------------------------COPY STRUCTURES ----------------------------------------
void ai_copy_movements(movements *src, movements *dst);
void ai_copy_state(stateGame *src, stateGame *cpy);

/************************* Print States *****************************/
void ai_print_state(stateGame *state);
//void ai_print_zones();
void ai_print_domRobots(stateGame *state);
void ai_print_movements(movements *mov);

#endif
